home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / linux-ab.1 / linux-abuse.1.1.0.tar / abuse-1.10 / lisp / people.lsp < prev    next >
Lisp/Scheme  |  1995-10-23  |  25KB  |  933 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.  
  4. (setq bright_tint (def_tint "art/tints/cop/bright.spe"))  ;; used when the player fires a weapon
  5. (setq player_tints (make-array 7 :initial-contents (list 
  6.                             0                                      ; this is not used
  7.                             (def_tint "art/tints/cop/blue.spe")   ; plasma
  8.  
  9.                             (def_tint "art/tints/cop/africa.spe")
  10.                             (def_tint "art/tints/cop/fire.spe")
  11.  
  12.                             (def_tint "art/tints/cop/olive.spe")
  13.                             (def_tint "art/tints/cop/land.spe")
  14.                             (def_tint "art/tints/cop/gold.spe")
  15.  
  16. )))
  17.  
  18. (setq player_text_color (make-array 7 :initial-contents (list 
  19.                              43       ; brown
  20.                              216      ; blue
  21.                              85       ; orange
  22.                              87       ; red
  23.                              165      ; olive
  24.                              148      ; green2
  25.                              78)))    ; orange
  26.  
  27.  
  28. (setq cop_dead_parts (make-array (* 4 3) :initial-contents 
  29.                    ;       head           arm            leg
  30.                  '((CP_1  "4dha") (CP_2  "4daa") (CP_3  "4dba")     ; disapear
  31.                    (CP_4  "4dhf") (CP_5  "4daf") (CP_6  "4dbf")     ; flaming
  32.                    (CP_7  "4dae") (CP_8  "4dle") (CP_9  "4dbe")     ; electrical
  33.                    (CP_10 "4dhn") (CP_11 "4dan") (CP_12 "4dbn"))))  ; normal
  34.  
  35.  
  36. (do ((i 0 (setq i (+ i 1))))
  37.        ((>= i 12) nil)
  38.        (setq (aref cop_dead_parts i) 
  39.          (make_dead_part (car (aref cop_dead_parts i))          
  40.                  (car (cdr (aref cop_dead_parts i))) 4 "art/cop.spe" 'dead_cop_part_draw)))
  41.  
  42.  
  43.  
  44.  
  45.  
  46. (setf fast_image (def_image "art/misc.spe" "fast_image"))
  47. (setf fly_image (def_image "art/misc.spe" "fly_image"))
  48. (setf sneaky_image (def_image "art/misc.spe" "sneaky_image"))
  49. (setf health_image (def_image "art/misc.spe" "b_check_image"))
  50.  
  51.  
  52.                                   
  53.  
  54. (defun give_player_health (amount)
  55.   (let ((h_amount  (select difficulty
  56.                ('easy    amount)
  57.                ('medium  (/ (* amount 3) 4))
  58.                ('hard    (/ amount 2))
  59.                ('extreme (/ amount 4))))
  60.     (h_max (if (eq special_power HEALTH_POWER)
  61.            200
  62.          100)))
  63.     (if (eq (hp) h_max)
  64.     nil
  65.       (progn
  66.     (if (<= (+ (hp) h_amount) h_max)
  67.         (add_hp h_amount)
  68.       (add_hp (- h_max (hp))))
  69.     (setq b_ramp (+ b_ramp (* h_amount 2)))
  70.  
  71.     T)))
  72. )
  73.     
  74.  
  75.  
  76. (defun pressing_action_key ()
  77.   (> (player_y_suggest) 0))
  78.  
  79.  
  80. ; signals for user function
  81. (enum 'SET_SNEAKY_TIME
  82.       'SET_VISOR_TIME
  83.       'SET_FAST_TIME
  84.       'SET_FADE_COUNT
  85. )
  86.  
  87.  
  88. ; states for cop
  89. (enum 'JUST_START
  90.       'NORMAL_PLAY)
  91.  
  92.  
  93. (enum 'NO_POWER
  94.       'FAST_POWER
  95.       'FLY_POWER
  96.       'SNEAKY_POWER
  97.       'HEALTH_POWER)
  98.  
  99. ; this is called by the engine when a level is loaded with no player_info in it
  100. ; i.e. not for savegames
  101. ; this function is called once for each player object
  102. (defun set_player_defaults ()
  103.   (set_ambient_light (me) 35)
  104.   (set_aistate 0)
  105.   (setq special_power NO_POWER))
  106.  
  107.  
  108.  
  109. (defun cop_ufun (signal value)
  110.   (if (< (total_objects) 1)    ; make sure upper body is there
  111.       nil
  112.     (select signal
  113.         (SET_SNEAKY_TIME 
  114.          (progn 
  115.            (set_sneaky_time value)
  116.            (with_obj0 (set_sneaky_time value))))
  117.         (SET_VISOR_TIME (set_visor_time value))
  118.         (SET_FAST_TIME 
  119.          (progn 
  120.            (set_fast_time value)
  121.            (with_obj0 (set_fast_time value))))
  122.         (SET_FADE_COUNT (set_fade_count value) 
  123.                 (with_obj0 (set_fade_count value)))
  124.          
  125.         )))
  126.             
  127.  
  128. (defun cop_adjust_top (return)
  129.   (if (< (total_objects) 1)        ;; should be here
  130.       (let ((me (me)))
  131.     (link_object (add_object_after MGUN_TOP (x) (y)))
  132.     (with_obj0 (link_object me))
  133.     ))
  134.   return
  135. )
  136.  
  137. (defun climb_off_handler ()
  138.   (if (next_picture)
  139.       (progn
  140.     (view_push_down 4)
  141.     0)
  142.     (progn
  143.       (set_y (- (y) 28))
  144.       (set_state stopped)
  145.       0)))
  146.  
  147. (defun climb_handler (xm ym but)
  148.   (let ((yd in_climbing_area))
  149.     (setq in_climbing_area 0)
  150.     (if (eq (state) climb_off)
  151.     (climb_off_handler)
  152.       (if (eq (state) climbing)
  153.       (progn
  154.         (if (> ym 0)
  155.         (progn
  156.           (if (eq (current_frame) 0) (set_current_frame 9) 
  157.             (set_current_frame (- (current_frame) 1)))
  158.           (set_y (+ (y) 3)))
  159.           (if (< ym 0)
  160.           (progn
  161.             (if (< yd 32)
  162.             (set_state climb_off)
  163.               (progn
  164.             (if (not (next_picture)) (set_state climbing))
  165.             (set_y (- (y) 3)))))))
  166.         (if (not (eq xm 0))
  167.         (if (can_see (x) (- (y) 20) (x) (y) nil)
  168.             (if (eq ym 0)
  169.             (progn
  170.               (set_state run_jump_fall)
  171.               (set_gravity 1))
  172.               (progn
  173.             (set_state run_jump)
  174.             (set_yvel (get_ability jump_yvel))
  175.             (set_gravity 1)
  176.             ))))
  177.  
  178.         0)
  179.     (if (and (>= (yvel) 0) (or (> ym 0) 
  180.                    (and (< ym 0) (> yd 8))))
  181.         (progn
  182.           (set_state climbing)
  183.           (set_gravity 0)
  184.           (set_xvel 0)
  185.           (set_yvel 0)
  186.           (set_xacel 0)
  187.           (set_yacel 0)
  188.           0)
  189.       (progn
  190.         (next_picture)
  191.         (cop_adjust_top (mover xm ym but))))
  192.     ))))
  193.       
  194.       
  195. (defun undo_special_power (xm ym but)
  196.   (select special_power
  197.       (FAST_POWER   (setq used_special_power 0))
  198.       (SNEAKY_POWER (if (> used_special_power 0)
  199.                 (setq used_special_power (- used_special_power 1))))))
  200.  
  201. (defun do_special_power (xm ym but)
  202.   (select special_power
  203.       (FLY_POWER
  204.        (add_object CLOUD (+ (+ (x) (* (direction) -10)) (random 5)) (+ (y) (random 5)))
  205.        (set_state run_jump)
  206.        (set_gravity 1)
  207.        (set_yacel 0)
  208.        (if (> (yvel) 0) (set_yvel (/ (yvel) 2)))
  209.        (set_yvel (- (yvel) 2))
  210.        (if (< ym 0)
  211.            (set_yvel (- (yvel) 1)))
  212.        )
  213.       
  214.  
  215.       (FAST_POWER 
  216.        (setq used_special_power 1)
  217.        (setq last1_x (x))
  218.        (setq last1_y (y))
  219.        (if (> (total_objects) 0)
  220.            (with_obj0
  221.                 (if (> fire_delay1 0) 
  222.                 (setq fire_delay1 (- fire_delay1 1)))))
  223.  
  224.        
  225.        (let ((in_area in_climbing_area)
  226.          (old_yvel (yvel)))
  227.          (player_move xm ym but)
  228.          (setq in_climbing_area in_area)
  229.          (if (and (< ym 0) (eq old_yvel 0) (< (yvel) 0))
  230.          (set_yvel (+ (yvel) (/ (yvel) 3))))
  231.          
  232.          )
  233.  
  234.        (setq last2_x (x))
  235.        (setq last2_y (y)))
  236.  
  237.       (SNEAKY_POWER (if (<= used_special_power 15)               
  238.                 (setq used_special_power (+ used_special_power 1))))
  239.       ))
  240.  
  241. (defun player_move (xm ym but)
  242.   (if (eq in_climbing_area 0)
  243.       (progn
  244.     (if (eq (state) climbing)
  245.         (progn
  246.           (set_gravity 1)
  247.           (set_state run_jump_fall)))
  248.     (next_picture)
  249.     (cop_adjust_top (mover xm ym but)))
  250.     (climb_handler xm ym but)))
  251.  
  252. /*(defun cop_mover (xm ym but) 
  253.   (if (> (yvel) 10) 
  254.       (progn 
  255.     (set_yacel 0)
  256.     (set_yvel (- (yvel) 1))))  ;; terminal velocity
  257.   (select (aistate)
  258.       (JUST_START 
  259.        (if (eq but 0)              ; wait till user lets go of button before moving           
  260.            (progn
  261.          (set_aistate NORMAL_PLAY)
  262.          (mover xm ym but))
  263.          (cop_adjust_top (tick))))
  264.       (NORMAL_PLAY
  265.        (if (or (<= (hp) 0) (eq (state) dieing) (eq (state) dead))    ; are we dead?
  266.            (progn
  267.          (if (not (eq (state) dead))
  268.              (if (not (eq (state) dieing))
  269.              (progn
  270.                (set_state dieing)
  271.                (set_xvel 0)
  272.                (set_yvel 0)
  273.                (set_xacel 0)
  274.                (set_yacel 0))
  275.                (if (not (next_picture))
  276.                (set_state dead) nil))
  277.            (if (not (eq but 0)) ; wait till dead and pressing but, then reset
  278.                (progn
  279.              (restart_player)
  280.              (set_aistate JUST_START))
  281.              (cop_adjust_top (tick))))
  282.          0)
  283.  
  284.          ; normal play code
  285.          (progn
  286.            ; check to see if player is firing
  287.            (if (equal (bit-and but 1) 1)
  288.            (do_special_power xm ym but)
  289.          (undo_special_power xm ym but))
  290.            
  291.            (let ((ret (player_move xm ym but))
  292.              (other (me)))
  293.          (with_obj0 
  294.                   (progn
  295.                 (set_x (with_object other (x)))
  296.                 (set_y (- (- (with_object other (y)) -29) 
  297.                       (with_object other (picture_height))))
  298.                 ))
  299.          (if (and (equal (bit-and but 2) 2)
  300.               (not (eq (state) dead)) (not (eq (state) dieing)))
  301.              (let ((ammo (ammo_total (current_weapon_type))))
  302.                (add_ammo (current_weapon_type) (with_obj0 
  303.                                     (user_fun 'FIRE ammo)))
  304.                nil))
  305.          ret)
  306.            )))))
  307.  
  308. )*/
  309.  
  310. ;;(defun normal_bottom_mover ()  ;; just runs around
  311.  
  312. (defun dead_cop_part_draw ()
  313.   (if (eq (aitype) 0)
  314.       (draw)
  315.     (draw_tint (aref player_tints (aitype)))))
  316.  
  317. (defun bottom_damage (amount from hitx hity push_xvel push_yvel)  ; transfer damage to lower half
  318.   (if (eq is_teleporting 1)
  319.       nil
  320.     (let ((amount (select difficulty;; reduce damage according to difficulty
  321.               ('easy   (/ amount 2))
  322.               ('medium (/ (* amount 3) 4))
  323.               ('hard    amount)
  324.               ('extreme (* amount 2))
  325.               )))
  326.  
  327.  
  328.       (select (aistate)
  329.           (NORMAL_PLAY (if (and (not (eq (state) dieing)) (not (eq (state) dead)))
  330.                    (progn
  331.                  (if (eq (random 2) 0)
  332.                      (set_state flinch_up)
  333.                    (set_state flinch_down))
  334.                  (if (local_player)
  335.                      (progn
  336.                        (setq r_ramp (+ r_ramp (* amount 7)))
  337.                        (setq g_ramp (- g_ramp (* amount 14)))
  338.                        (setq b_ramp (- b_ramp (* amount 14)))
  339.                        (if (> r_ramp 120) (setq r_ramp 120))
  340.                        (if (< g_ramp 0) (setq g_ramp 0))
  341.                        (if (< b_ramp 0) (setq b_ramp 0))))
  342.  
  343.                  (damage_fun amount from hitx hity (/ push_xvel 2) (/ push_yvel 2))
  344.                  (if (eq (hp) 0)
  345.                      (progn
  346.                        (create_dead_parts cop_dead_parts (* (get_dead_part from) 3) (player_number))
  347.                        (play_sound (aref PLAYER_DEATH (random 4)) 127 (x) (y)))
  348.                    (if (> amount 8)
  349.                        (play_sound (aref PLAYER_PAIN (random 4)) 127 (x) (y)))))))
  350.  
  351.  
  352.           ))) 
  353.   )
  354.  
  355. (defun should_draw_top? (mode)
  356.   (select mode
  357.       (JUST_START T)
  358.       (NORMAL_PLAY T)))
  359.          
  360. (defun change_mode (new_mode)
  361.   (setq disable_top_draw (if (should_draw_top? new_mode) 0 1))
  362.   (set_aistate new_mode))
  363.  
  364. (defun draw_fast ()
  365.   (put_image (- (view_x2) 20) (+ (view_y1) 5) fast_image)
  366.                (if (eq used_special_power 1)
  367.                (if (> (total_objects) 0)            
  368.                    (let ((nowx (x))
  369.                      (nowy (y))
  370.                      (l2x last2_x)
  371.                      (l2y last2_y)
  372.                      (l1x last1_x)
  373.                      (l1y last1_y)
  374.                      (td (top_draw_state (state)))
  375.                      (h   (picture_height)))
  376.  
  377.                  (set_x l2x)
  378.                  (set_y l2y)
  379.                  (draw_transparent 5 16)
  380.                  (if td (with_obj0 (progn (set_x l2x)
  381.                                     (set_y (- (- l2y -29) h))
  382.                                     (draw_transparent 5 16))))
  383.                  (set_x last1_x)
  384.                  (set_y last1_y)
  385.                  (draw_transparent 10 16)
  386.  
  387.                  (if td (with_obj0 (progn (set_x l1x)
  388.                                     (set_y (- (- l1y -29) h))
  389.                                     (draw_transparent 10 16)
  390.                                     (set_x nowx)
  391.                                     (set_y nowy)
  392.                                     )))
  393.  
  394.                  (set_x nowx)
  395.                  (set_y nowy)))))
  396.  
  397. (defun sneaky_draw (count num)
  398.   (if (eq count 0)
  399.       (player_draw num)
  400.     (if (> count 15)
  401.     (draw_predator)
  402.       (draw_transparent count 16))))
  403.  
  404. (defun player_draw (num)
  405.   (if (eq num 0) 
  406.       (if (eq just_fired 1)           ;; if they just fired a weapon, draw them lite up.. use the bright tint
  407.       (progn
  408.         (draw_tint bright_tint)
  409.         (setq just_fired 0))      ;; ok to change this in the draw function only if it is not accessed anywhere else!
  410.     (draw))
  411.     (if (eq just_fired 1)    
  412.     (progn
  413.       (draw_double_tint (aref player_tints num) bright_tint)
  414.       (setq just_fired 0))      ;; ok to change this in the draw function only if it is not accessed anywhere else!      
  415.       (draw_tint (aref player_tints num)))))
  416.  
  417. /*(defun bottom_draw ()
  418.   (if (not (and (eq r_ramp 0)    ;; need to draw red palette
  419.         (eq g_ramp 0)
  420.         (eq b_ramp 0)))
  421.       (progn
  422.     (if (> r_ramp 7)
  423.         (setq r_ramp (- r_ramp 7))
  424.       (if (< r_ramp -7)
  425.           (setq r_ramp (+ r_ramp 7))
  426.         (setq r_ramp 0)))
  427.  
  428.     (if (> g_ramp 7)
  429.         (setq g_ramp (- g_ramp 7))
  430.       (if (< g_ramp -7)
  431.           (setq g_ramp (+ g_ramp 7))
  432.         (setq g_ramp 0)))
  433.  
  434.     (if (> b_ramp 7)
  435.         (setq b_ramp (- b_ramp 7))
  436.       (if (< b_ramp -7)
  437.           (setq b_ramp (+ b_ramp 7))
  438.         (setq b_ramp 0)))
  439.  
  440.     (if (local_player)    
  441.         (tint_palette r_ramp g_ramp b_ramp))))
  442.  
  443.  
  444.   (select (aistate)
  445.       (JUST_START (player_draw (player_number)))
  446.       (NORMAL_PLAY 
  447.        (select special_power
  448.            (NO_POWER (player_draw (player_number)))
  449.            (HEALTH_POWER (player_draw (player_number)) 
  450.                 (put_image (- (view_x2) 20) (+ (view_y1) 5) health_image))
  451.            (FAST_POWER (draw_fast) (player_draw (player_number)))
  452.            (FLY_POWER   (player_draw (player_number)) 
  453.                 (put_image (- (view_x2) 20) (+ (view_y1) 5) fly_image))
  454.            (SNEAKY_POWER (put_image (- (view_x2) 20) (+ (view_y1) 5) sneaky_image)
  455.                  (sneaky_draw used_special_power (player_number)))
  456.       ))))*/
  457.  
  458. (defun restart_player ()
  459.   (setq special_power 0)
  460.   (setq has_compass 0)
  461.   (if (and (local_player) (not (and (eq r_ramp 0)
  462.                     (eq g_ramp 0)
  463.                     (eq b_ramp 0))))
  464.       (progn
  465.     (setq r_ramp 0)
  466.     (setq g_ramp 0)
  467.     (setq b_ramp 0)
  468.     (tint_palette 0 0 0)))
  469.  
  470.   (if (eq (total_players) 1)     ;; is this a single player game?
  471.       (request_level_load  (if (eq has_saved_this_level 0) 
  472.                    (progn
  473.                  (set_hp 100)
  474.                  (level_name))
  475.                  (concatenate 'string "save" (digstr has_saved_this_level 4) ".spe")))
  476.     (reset_player)
  477.  
  478.     ))
  479.  
  480.  
  481.  
  482. (defun start_cache (type) 
  483.   `((,DARNEL) nil))
  484.  
  485. (def_char START
  486.   (funs (ai_fun   do_nothing)
  487.     (get_cache_list_fun start_cache)
  488.     (draw_fun dev_draw))
  489.   (range 0 0)
  490.   (states "art/misc.spe" (stopped "start_image")))
  491.  
  492.  
  493. (defun cop_cache (type)
  494.   `(() (,bright_tint)))
  495.  
  496. (defun p_compass_draw (player)
  497.   (if player
  498.       (with_object player
  499.            (let ((spot (game_to_mouse (x) (y))))
  500.              (draw_rect (- (first spot) 1)
  501.                 (- (second spot) 1)
  502.                 (+ (first spot) 1)
  503.                 (+ (second spot) 1)
  504.                 (aref player_text_color (player_number))))
  505.            (p_compass_draw (next_focus player)))))
  506.   
  507.  
  508. (defun compass_draw ()
  509.   (if (and (local_player) (eq (mod (game_tick) 2) 0))
  510.       (if (eq has_compass 1)
  511.       (p_compass_draw (first_focus))
  512.     (let ((spot (game_to_mouse (x) (y))))
  513.       (draw_rect (- (first spot) 1)
  514.              (- (second spot) 1)
  515.              (+ (first spot) 1)
  516.              (+ (second spot) 1)
  517.              (aref player_text_color (player_number)))))))
  518.  
  519.  
  520. (def_char DARNEL
  521.   (vars in_climbing_area
  522.     disable_top_draw
  523.     just_hit
  524.     ship_pan_x
  525.     special_power
  526.     used_special_power
  527.     last1_x last1_y
  528.     last2_x last2_y
  529.     has_saved_this_level
  530.     r_ramp g_ramp b_ramp
  531.     is_teleporting
  532.     just_fired
  533.     has_compass
  534.     )
  535.   (range 50 50)
  536.   (abilities (walk_top_speed    3)
  537.          (jump_yvel       -15)
  538.          (run_top_speed     9)
  539.          (jump_top_speed   10)
  540.          (jump_xvel         9)
  541.          (stop_accel        9)
  542.          (start_accel       8)
  543.          (start_hp        100)
  544.          (hamper_xrange    80)
  545.          (push_xrange       9))
  546.  
  547.   (flags     (hurtable          T)
  548.          (unlistable        T))
  549.  
  550.   (funs (move_fun           cop_mover)
  551.     (damage_fun         bottom_damage)
  552.     (draw_fun           bottom_draw)
  553.     (map_draw_fun       compass_draw)
  554.     (get_cache_list_fun cop_cache)
  555.     (user_fun           cop_ufun))
  556.  
  557.   (states "art/cop.spe"
  558.           (stopped            (seq "stopped" 1 6))
  559.       (running            (seq "4wlk" 1 10))
  560.  
  561.       (fast_running       (seq "4fst" 1 10))
  562.       (fly_running        (seq "4fly" 1 10))
  563.  
  564.       (fast_stopped        (seq "bot2" 7 12))
  565.       (fly_stopped       (seq "bot2" 1 6))
  566.  
  567.       (dead               "dead")
  568.  
  569.       (start_run_jump     "jump_up")
  570.       (run_jump           "jump_up")
  571.       (run_jump_fall      "jump_down")
  572.       (end_run_jump       (seq "4jmp" 3 5))
  573.  
  574.       (fly_start_run_jump     "4flj0002.pcx")
  575.       (fly_run_jump           "4flj0002.pcx")
  576.       (fly_run_jump_fall      "4flj0003.pcx")
  577.       (fly_end_run_jump       (seq "4flj" 4 6))
  578.  
  579.       (fast_start_run_jump     "4fjp0002.pcx")
  580.       (fast_run_jump           "4fjp0002.pcx")
  581.       (fast_run_jump_fall      "4fjp0003.pcx")
  582.       (fast_end_run_jump       (seq "4fjp" 4 6))
  583.  
  584.  
  585.       (flinch_up           (rep "4flh0002.pcx" 4))
  586.       (flinch_down         (rep "4flh0003.pcx" 4))
  587.  
  588.       (climbing             (seq "4lad" 1 10))
  589.       (climb_off            (seq "4off" 1 8))
  590.       (climb_on            (seq "4off" 8 1))
  591.       ))
  592.  
  593.   
  594. (defun clone_ai ()
  595.   (if (and (< (state_time) 200) (not (eq (state) dead)))
  596.       (progn
  597.     (select (direction)
  598.         (1 (if (blocked_right (move 1 0 0))
  599.                (set_direction -1)
  600.              nil))
  601.         (-1 (if (blocked_left (move -1 0 0))
  602.             (set_direction 1)
  603.               nil)))        
  604.         (if (or (> (state_time) 185) (eq (state) dieing))
  605.         (set_fade_count (+ (fade_count) 1))
  606.           nil)        
  607.         T)
  608.     nil))
  609.  
  610.  
  611.  
  612.  
  613. (defun top_draw_state (state)
  614.  
  615.   (or (eq state stopped) (eq state running)
  616.             (eq state run_jump) (eq state run_jump_fall) 
  617.             (eq state end_run_jump)))
  618.  
  619. /*(defun top_draw ()
  620.   (if (> (total_objects) 0)
  621.       (let ((other  (get_object 0)))
  622.     (if (or (with_object other (morphing)) 
  623.         (eq (with_object other disable_top_draw) 1)
  624.         (not (top_draw_state (with_object other (state)))))
  625.         nil
  626.       (progn
  627.         (if (eq (with_object other special_power) SNEAKY_POWER)
  628.         (sneaky_draw (with_object other used_special_power)
  629.                  (with_object other (player_number)))
  630.           (let ((nowx (x))
  631.             (nowy (y)))                
  632.         (set_x (with_object other (if (> (direction) 0) (x) (+ (x) 2))))
  633.         (set_y (- (- (with_object other (y)) -29) (with_object other (picture_height))))
  634.         (player_draw  (with_object other (player_number)))
  635.         (set_x nowx)
  636.         (set_y nowy))
  637.           ))))))
  638. */
  639.  
  640. (defun ammo_type ()
  641.   (select (otype)
  642.       (GRENADE_TOP  2)
  643.       (MGUN_TOP     10)
  644.       (FIREBOMB_TOP 5)
  645.       (ROCKET_TOP   3)
  646.       (PGUN_TOP     4)
  647.       (LSABER_TOP   5)
  648.       (DFIRS_TOP    6)
  649.       ))
  650.  
  651. (defun ammo_delay ()
  652.   0)
  653.  
  654.  
  655. (defun player_angle_suggestion ()
  656.   (atan2 (- (y) (player_pointer_y) 16)
  657.      (- (player_pointer_x) (x))))
  658.  
  659.  
  660. (defun player_fire_weapon (type target)
  661.   (let ((angle (with_obj0 (player_angle_suggestion))))
  662.                 
  663.     (let ((firex (+ (x) (* (cos angle) 17) (xvel)))
  664.       (firey (+ (- (y) (* (sin angle) 16) 20) (yvel))))
  665.       (if (can_see (x) (- (y) 16) firex firey nil)    
  666.       (progn
  667.         (fire_object  (get_object 0) type firex firey angle target)
  668.         T)
  669.     nil))))
  670.  
  671. /* (defun top_ai () 
  672.   (if (> (total_objects) 0)
  673.       (let ((myself (get_object 0)))
  674.       
  675.     (set_state rotate)
  676.     (let ((angle (with_object myself 
  677.                         (if (> (direction) 0)
  678.                         (player_angle_suggestion)
  679.                           (if (> (player_angle_suggestion) 180)
  680.                           (- (player_angle_suggestion) 180)
  681.                         (+ 180 (player_angle_suggestion)))))))
  682.       (setq point_angle angle)
  683.       (set_frame_angle 0 359 angle))
  684.     (if (not (eq fire_delay1 0))
  685.         (setq fire_delay1 (- fire_delay1 1)))
  686.     (if (eq (with_object myself (weapon_to_type (current_weapon_type))) (otype))
  687.         (select (aistate)
  688.             (2            ; start fire up
  689.              (progn 
  690.                (set_state rotate_fire)
  691.                (set_frame_angle 0 359 (with_object myself 
  692.                         (if (> (direction) 0)
  693.                         (player_angle_suggestion)
  694.                           (if (> (player_angle_suggestion) 180)
  695.                           (- (player_angle_suggestion) 180)
  696.                           (+ 180 (player_angle_suggestion))))))
  697.                ;; (set_state weapon_fire)
  698. ;;               (set_fire_delay1 3)
  699.  
  700. ;;                (let ((otype (otype)))
  701. ;;                  (with_object myself (add_ammo otype -1)))
  702. ;;                (with_object (add_object (ammo_type) (x) (- (y) 16) 1) 
  703. ;;                     (user_fun myself))
  704.               (set_aistate 3)))
  705.             (1            ; special power
  706.              (progn (set_state weapon_fire_up)
  707.                 (let ((otype (otype)))
  708.                   (with_object myself (add_ammo weapon_type -1)))
  709.                 (with_object (add_object (ammo_type) (x) (- (y) 20) 2)
  710.                      (user_fun myself))
  711.                 (set_aistate 3)))
  712.             (3 (if (eq fire_delay1 0) ;; (user_fun 'RESET_FIRE_OK nil)
  713.                (set_aistate 0)
  714.              (progn
  715.                (user_fun 'CONTINUE_FIRE nil)
  716.                (setq fire_delay1 (- fire_delay1 1)))
  717.              )))
  718.       (set_otype (with_object myself (weapon_to_type (current_weapon_type)))))))
  719.   (move 0 0 0) 
  720.   T)
  721.  
  722. ;(defun top_damage (amount from hitx hity push_xvel push_yvel)  ; transfer damage to lower half
  723. ;  (with_obj0 (damage_fun amount from hitx hity push_xvel push_yvel)))
  724.  
  725.  
  726. (defun laser_ufun (signal value)
  727.   (select signal
  728.       ('FIRE (if (eq (aistate) 0)  ;;  not already firing
  729.              (if (> value 0)   ;; have ammo         
  730.              (progn               
  731.                (setq fire_delay1 3)
  732.                (set_aistate 2)
  733.                (if (player_fire_weapon (ammo_type) nil)
  734.                    -1
  735.                  0))
  736.                (progn               
  737.              (setq fire_delay1 7)
  738.              (set_aistate 2)
  739.              (player_fire_weapon (ammo_type) nil)
  740.  
  741.              0))
  742.            0))      
  743.       ('RESET_FIRE_OK (>= (state_time) fire_delay1))))
  744.  
  745. (defun top_ufun (signal value)
  746.   (select signal
  747.       ('FIRE (if (and (> value 0) (eq (aistate) 0))  ;; have ammo and not already firing
  748.              (progn
  749.                (setq fire_delay1 12)
  750.                (set_aistate 2)
  751.                (if (player_fire_weapon (ammo_type) nil)
  752.                -1
  753.              0))
  754.            0))
  755.       ('RESET_FIRE_OK (>= (state_time) fire_delay1))))
  756.  
  757.  
  758.  
  759. (defun plaser_ufun (signal value)
  760.   (select signal
  761.       ('FIRE (if (and (> value 0) (eq (aistate) 0))  ;; have ammo and not already firing
  762.              (progn
  763.                (setq fire_delay1 2)
  764.                (set_aistate 2)
  765.                (if (player_fire_weapon (ammo_type) nil)
  766.                -1 0))
  767.            0))
  768.  
  769.       ('RESET_FIRE_OK (>= (state_time) fire_delay1))))
  770.  
  771.  
  772.  
  773. (defun player_rocket_ufun (signal value)
  774.   (select signal
  775.       ('FIRE (if (and (> value 0) (eq (aistate) 0))  ;; have ammo and not already firing
  776.              (progn
  777.                (setq fire_delay1 12)
  778.                (set_aistate 2)
  779.                (if (player_fire_weapon (ammo_type) 
  780.                        (with_obj0 (find_object_in_area 
  781.                                     (- (x) 160) (- (y) 160)
  782.                                     (+ (x) 160) (+ (y) 160) 
  783.                                     bad_guy_list)))
  784.                -1 0))
  785.            0))
  786.       ('RESET_FIRE_OK (>= (state_time) fire_delay1)))) */
  787.  
  788.  
  789.  
  790.  
  791. (defun top_cache (type)
  792.   (list
  793.    (select type
  794.        (MGUN_TOP      (list SHOTGUN_BULLET))
  795.        (GRENADE_TOP   (list GRENADE))
  796.        (ROCKET_TOP    (list ROCKET))
  797.        (FIREBOMB_TOP  (list FIREBOMB))
  798.        (PGUN_TOP      (list PLASMAGUN_BULLET))
  799.        (LIGHT_SABER   (list LSABER_BULLET))
  800.        (DFRIS_TOP     (list DFRIS_BULLET))
  801.    nil)))
  802.         
  803.  
  804. (defun make_top_char (symbol base ufun dfun)
  805.   (eval (list 'def_char symbol
  806.           `(funs (ai_fun    top_ai)
  807.              (get_cache_list_fun top_cache)
  808.              (draw_fun  ,dfun)
  809.              (user_fun  ,ufun))
  810.           '(flags (add_front  T)
  811.               (is_weapon  T)
  812.               (unlistable T))
  813.           '(vars point_angle fire_delay1 just_fired)
  814.           `(states "art/coptop.spe"
  815.                (stopped        (seq ,base 1 24))))))
  816.  
  817.           
  818.  
  819. (make_top_char 'MGUN_TOP     "4gma" 'laser_ufun         'top_draw)
  820. (make_top_char 'GRENADE_TOP  "4gre" 'top_ufun           'top_draw)
  821. (make_top_char 'ROCKET_TOP   "4gro" 'player_rocket_ufun 'top_draw)
  822. (make_top_char 'FIREBOMB_TOP "4gfi" 'top_ufun           'top_draw)
  823.  
  824.  
  825.  
  826.  
  827. (defun restart_ai ()
  828.   (if (eq (total_players) 1)       ;; only allow saving in single player games
  829.       (select (aistate)
  830.           (0 (next_picture)
  831.          (if (and (touching_bg) (with_object (bg) (pressing_action_key)))
  832.              (set_aistate 2)))
  833.           (1 (next_picture);; wait for save (actived state)
  834.          (if (and (touching_bg) (with_object (bg) (pressing_action_key)))
  835.              (set_aistate 2)))
  836.           (2 (set_state running)       
  837.          (set_aistate 3))
  838.           (3 (set_aistate 4))        
  839.           (4 
  840.            (let ((spot (get_save_slot)))
  841.          (set_state stopped)
  842.          (set_aistate 1)
  843.          (if (not (eq spot 0));; did they escape ?
  844.              (progn
  845.                (show_help (concatenate 'string "Station #" (num2str (xvel)) " secured!"))
  846.                (with_object (bg)
  847.                     (progn
  848.                       (let ((old_hp (hp)))
  849.                     (if (not (eq difficulty 'extreme))
  850.                         (set_hp 100));; save the player with 100 health, unless on extreme
  851.                     (play_sound SAVE_SND 127 (x) (y))
  852.                     (setq has_saved_this_level spot)
  853.                     (save_game (concatenate 'string "save" (digstr spot 4) ".spe"))
  854.                     (set_hp old_hp)
  855.                     ))))))
  856.  
  857.            )))
  858.   T)
  859.       
  860.  
  861. (def_char RESTART_POSITION
  862.   (funs (ai_fun restart_ai)
  863.     (reload_fun lower_reload))
  864.   (fields ("xvel" "station number"))
  865.   (states "art/misc.spe"
  866.       (stopped (app (rep "console" 3) (rep "console2" 3)))
  867.       (running (rep "console_on" 2))))
  868.  
  869. (defun next_level_ai ()
  870.   (if (and (touching_bg) (with_object (bg) (pressing_action_key)))
  871.       (if (eq (aistate) end_level)
  872.       (request_end_game)
  873.     (request_level_load (concatenate 'string "levels/level" (digstr (aistate) 2) ".spe"))))
  874.   T)
  875.     
  876.  
  877. (def_char NEXT_LEVEL
  878.   (funs (ai_fun next_level_ai)) 
  879.   (flags (can_block T))
  880.   (fields ("aistate" "next_level"))
  881.   (states "art/misc.spe"
  882.       (stopped "end_port2")))
  883.  
  884. (defun next_level_top_ai ()
  885.   (shift_rand_table 80)
  886.   (let ((oldy (y)))
  887.     (try_move 0 100)
  888.     (setq floor_yoff (- (y) oldy))
  889.     (set_y oldy))
  890.   T)
  891.  
  892. (def_char NEXT_LEVEL_TOP
  893.   (funs (ai_fun next_level_top_ai))
  894.   (vars floor_yoff)
  895.   (draw_range 50 100)
  896.   (fields ("aistate" "next_level"))
  897.   (states "art/misc.spe"
  898.       (stopped "end_port1")))
  899.  
  900. (defun tele_beam_ai ()
  901.   (next_picture)
  902.   (if (> (direction) 0)
  903.       (if (eq (fade_count) 12)
  904.       (progn
  905.         (play_sound APPEAR_SND 100 (x) (y))
  906.         (set_direction -1))
  907.     (set_fade_count (+ (fade_count) 1)))
  908.     (if (eq (fade_count) 5)
  909.     (progn
  910.       (play_sound APPEAR_SND 100 (x) (y))
  911.       (set_direction 1))
  912.       (set_fade_count (- (fade_count) 1)))))
  913.     
  914.              
  915. (def_char TELE_BEAM
  916.   (funs (ai_fun tele_beam_ai))
  917.   (states "art/chars/teleport.spe" (stopped (seq "beam" 1 5))))
  918.  
  919. (def_char END_OF_S
  920.   (funs (ai_fun do_nothing))
  921.   (states "art/misc.spe" (stopped "eos")))
  922.  
  923. (setq load_warn nil)
  924. (if (load "register/people.lsp")
  925.     (setq end_level 19)
  926.   (setq end_level 5))
  927. (setq load_warn T)
  928.  
  929.  
  930.  
  931.  
  932.  
  933.